﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("输入的数为4和10：");
            Console.WriteLine("两数最大公约数为：{0}", MyMath.Maxi(4, 10));

            Console.WriteLine("两数最小公倍数：{0}", MyMath.Mini(4, 10));
            Console.WriteLine("*****************************************");

           
            Console.ReadKey();
        }
    }

    /// <summary>
    /// 自定义数学函数库
    /// </summary>
    class MyMath
    {

        /// <summary>
        /// 求两数最大公约数
        /// </summary>
        /// <param name="a">数据一</param>
        /// <param name="b">数据二</param>
        /// <returns>最大公约数</returns>
        public static int Maxi(int a, int b)
        {
            if (a < b)
            {
                a = a + b;
                b = a - b;
                a = a - b;
            }
            return (a % b == 0) ? b : Maxi(a % b, b);

        }
        /// <summary>
        /// 求两数最小公倍数
        /// </summary>
        /// <param name="a">数据一</param>
        /// <param name="b">数据二</param>
        /// <returns>最小公倍数</returns>
        public static int Mini(int a, int b)
        {
            return a * b / Maxi(a, b);

        }

    }
}
    

